package com.ruoyi.web.controller.storage;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.purchase.domain.PoType;
import com.ruoyi.purchase.service.PoDetailService;
import com.ruoyi.purchase.service.PoTypeService;
import com.ruoyi.storage.domain.RepoKc;
import com.ruoyi.storage.domain.RepoRk;
import com.ruoyi.storage.service.RepoKcService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.HashSet;
import java.util.List;

@Controller
@RequestMapping("/storage/kc")
public class StorageKCController extends BaseController {
    @Autowired
    private RepoKcService repoKcService;

    @Autowired
    private PoTypeService poTypeService;

    @RequiresPermissions("storage:rk:view")
    @RequestMapping()
    public String view(Model model) {
        List<PoType> list = poTypeService.list();
        model.addAttribute("types", list);
        return "storage/kc/storage";
    }

    @RequestMapping("/list")
    @ResponseBody
    public TableDataInfo list(RepoKc repoKc) {
        startPage();
        List<RepoKc> all = repoKcService.getAll(repoKc);

        return getDataTable(all);
    }
}
